#ifndef _INC_RAYTRACER_OBJECT
#define _INC_RAYTRACER_OBJECT

#include "Shape.h"
#include <stdlib.h>
#include <SFML\Graphics.hpp>
#include <iostream>

class Object
{
protected:
	Color4 color;
	double reflectance;
	int maxShapes, currentShapes;

    virtual void resize(){};

public:
	Object():
	maxShapes(32),
	currentShapes(0){};

	void setReflectance(double ref) { reflectance = ref; }

	void setColor(Color4 col) { color = col; }

	Color4 getColor() { return color; }

	double getReflectance() { return reflectance; }

    virtual void Test(){};

	virtual void getIntercept(Point3 startPoint,
                      Point3 direction,
                      double * interceptTime,
                      Point3 * interceptPoint,
                      Point3 * interceptNormal )
    {
        int y = 3;
    }
};

class PlaneObject : public Object
{
protected:
	Plane * planeList;
	void resize();

public:
    PlaneObject()
    {
        planeList = (Plane*) malloc (maxShapes*sizeof(Plane));
    }

	void addPlane(Point3 center, Point3 vec1, Point3 vec2, double width, double length);
	void addPlane(Plane p);

    void Test();

	virtual void getIntercept(Point3 startPoint,
                      Point3 direction,
                      double * interceptTime,
                      Point3 * interceptPoint,
                      Point3 * interceptNormal );
};

class SphereObject : public Object
{
protected:
	Sphere * sphereList;
	void resize();

public:
    SphereObject()
    {
        sphereList = (Sphere*) malloc (maxShapes*sizeof(Sphere));
    }
	void addSphere(Point3 center, double radius);

	virtual void getIntercept(Point3 startPoint,
                      Point3 direction,
                      double * interceptTime,
                      Point3 * interceptPoint,
                      Point3 * interceptNormal );
};

class LightPoint
{
private:
	Point3 location;
	double intensity;
	Color4 color;

public:
	LightPoint() {};

	LightPoint(Point3 loc, Color4 col, double inten = 1)
	{
		location = loc;
		intensity = inten;
		color = col;
	}

	Point3 getLocation() { return location; }
	Color4 getColor() { return color; }
	double getIntensity() { return intensity; }
};

//May need to add rotation and skew later so they don't look so boring.
PlaneObject * createSquare(Point3 center, double width, double height, double depth, Color4 color, double reflectance);
PlaneObject * createSquare(Point3 center, double width, double height, 
	double depth, Color4 color, double reflectance, double xRot, 
	double yRot, double zRot);
SphereObject * createSphere(Point3 center, double radius, Color4 color, double reflectance);

Point3 rotateVector(Point3 vec, float rotMatrix[16]);

#endif